<template>
	<!-- 邀请有奖 -->
	<view class="container" v-if="isloding">
		<image src="../../static/bg.png" mode=""></image>
		<view class="box">
			<view class="title">
				我的优惠
			</view>
			<view class="card">
				<view class="card_name">
					{{info.name}}
				</view>
				<!-- <view class="num">
					×3
				</view> -->
				<view class="name">
					￥{{info.moeny}}元优惠卷
				</view>
				<!-- <view class="time">
					活动时间至<br />2019-08-09
				</view> -->
				<view class="condition">
					满{{info.full}}可用
				</view>
				<!-- <view class="btn">
					已选择
				</view> -->
			</view>
		</view>
		<view class="Invitation" @tap="share">
			立即邀请
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userId:'',
				info:'',
				isloding:false
			};
		},
		onLoad() {
			uni.showLoading({
				title: '加载中',
				mask: false
			});
			uni.getStorage({
			    key: 'user',
			    success: (res)=> {
			        // console.log(res);
					this.userId=res.data.id
			    }
			});
			uni.request({
				url: this.webUrl+'/index/site/shareCoupon',
				method: 'GET',
				data: {},
				success: res => {
					console.log(res)
					this.info=res.data.data
					uni.hideLoading()
					this.isloding=true
				},
				fail: () => {},
				complete: () => {}
			});
		},
		methods:{
			share(){
				// uni.share({
				//     provider: 'weixin',
				//     scene: "WXSceneSession",
				//     type: 5,
				//     imageUrl: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/app/share-logo@3.png',
				//     title: '快来体验轻松吊运',
				//     miniProgram: {
				//         id: 'gh_ddaa4925070b',
				//         path: 'pages/index/index',
				//         type: 2,
				//         webUrl: 'http://uniapp.dcloud.io'
				//     },
				//     success: ret => {
				//         console.log(JSON.stringify(ret));
				//     }
				// });
				uni.share({
				    provider: "weixin",
				    scene: "WXSceneSession",
				    type: 0,
				    href: "http://diaoyila.90buluo.com/h5/index.html?id="+this.userId,
				    title: "吊易拉分享",
				    summary: "我正在使用吊易拉，赶紧跟我一起来体验！",
				    imageUrl: "https://wx.qlogo.cn/mmhead/Q3auHgzwzM76jGaNdQFgPmq9Uz3hJHgrjLFI568utfxx8tib8P7JEYg/0",
				    success: function (res) {
				        console.log("success:" + JSON.stringify(res));
				    },
				    fail: function (err) {
				        console.log("fail:" + JSON.stringify(err));
				    }
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	uni-page-body {
		height: 100%;
	}

	page {
		height: 100%;
	}

	.container {
		position: absolute;
		left: 0;
		bottom: 0;
		top: 0;
		right: 0;
		background: #f2f2f2;

		image {
			width: 100%;
			height: 300upx;
		}

		.box {
			width: 92%;
			margin: 30upx auto 0;
			padding-bottom: 20upx;
			border-radius: 30upx;
			background: #FFFFFF;

			.title {
				height: 80upx;
				background: #FE5621;
				border-radius: 30upx 30upx 0px 0px;
				font-size: 30upx;
				line-height: 80upx;
				padding-left: 30upx;
				font-family: Microsoft YaHei;
				font-weight: bold;
				color: rgba(255, 255, 255, 1);
			}

			.card {
				background-image: url(../../static/card.png);
				background-size: 653upx 255upx;
				margin: 30upx auto 0;
				position: relative;
				width: 653upx;
				height: 255upx;

				.card_name {
					position: absolute;
					left: 37upx;
					top: 23upx;
					font-size: 29upx;
					font-family: Microsoft YaHei;
					font-weight: 400;
					color: rgba(52, 52, 52, 1);
				}

				.num {
					position: absolute;
					right: 23upx;
					top: 34upx;
					font-size: 29upx;
					font-family: Microsoft YaHei;
					font-weight: 400;
					color: rgba(52, 52, 52, 1);
				}

				.name {
					position: absolute;
					left: 76upx;
					top: 75upx;
					font-size: 54upx;
					font-family: Microsoft YaHei;
					font-weight: 400;
					color: rgba(52, 52, 52, 1);
				}

				.time {
					position: absolute;
					right: 38upx;
					top: 80upx;
					font-size: 23upx;
					font-family: Microsoft YaHei;
					font-weight: 400;
					color: rgba(52, 52, 52, 1);
				}

				.condition {
					position: absolute;
					left: 76upx;
					bottom: 39upx;
					font-size: 29upx;
					font-family: Microsoft YaHei;
					font-weight: 400;
					color: rgba(52, 52, 52, 1);
				}

				.btn {
					position: absolute;
					right: 35upx;
					bottom: 31upx;
					width: 126upx;
					height: 49upx;
					font-size: 23upx;
					text-align: center;
					line-height: 49upx;
					font-family: Microsoft YaHei;
					font-weight: 400;
					color: rgba(255, 255, 255, 1);
					background: rgba(153, 153, 153, 1);
					border-radius: 10upx;
				}
			}
		}

		.Invitation {
			margin: 100upx auto 0;
			text-align: center;
			line-height: 98upx;
			font-size: 30upx;
			font-family: Microsoft YaHei;
			font-weight: bold;
			color: rgba(255, 255, 255, 1);
			width: 240upx;
			height: 98upx;
			background: rgba(254, 86, 33, 1);
			border-radius: 10upx;
		}
	}
</style>
